package isp.apps.example.shoppingcart.persistence.hibernate;

import isp.apps.example.shoppingcart.domain.ShippingOption;
import isp.apps.example.shoppingcart.persistence.PersistenceManagerFactory;
import isp.apps.example.shoppingcart.persistence.ShippingOptionsRepository;

import isp.utils.cjis.persistence.PersistenceException;
import isp.utils.cjis.persistence.PersistenceManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HibernateShippingOptionsRepository implements ShippingOptionsRepository
{
  private PersistenceManager persistenceManager = PersistenceManagerFactory
    .getPersistenceManager();

  private static final Log log =
    LogFactory.getLog(HibernateCartItemsRepository.class);
  public HibernateShippingOptionsRepository()
  {
  }
  public void saveShippingOption(ShippingOption so)
  {
    try
    {
      if (so.getId() == null)
        persistenceManager.save(so);
      else
        persistenceManager.update(so);
    }
    catch (PersistenceException pe)
    {
      log.error(pe, pe);
    }
  }

  public void deletesaveShippingOption(ShippingOption so)
  {
    try
    {
      persistenceManager.delete(so);
    }
    catch (PersistenceException pe)
    {
      log.error(pe, pe);
    }
  }
}
